﻿
// MFCApplication1View.h: CMFCApplication1View 类的接口
//

#pragma once

#include "AIS_ViewController.hxx"
#include "AIS_MyGrid.h"

enum CurAction3d
{
	CurAction3d_Nothing,
	CurAction3d_DynamicZooming,
	CurAction3d_WindowZooming,
	CurAction3d_DynamicPanning,
	CurAction3d_GlobalPanning,
	CurAction3d_DynamicRotation,
	CurAction3d_VertexSelection,
	CurAction3d_EdgeSelection,
	CurAction3d_FaceSelection,
	CurAction3d_SolidSelection,
	CurAction3d_SelectionTool
};

class SelectionTool;

class CMFCApplication1View : public CView, public AIS_ViewController
{
protected: // 仅从序列化创建
	CMFCApplication1View() noexcept;
	DECLARE_DYNCREATE(CMFCApplication1View)

	std::vector<Handle(AIS_Shape)> vShapes;

// 特性
public:
	CMFCApplication1Doc* GetDocument() const;

	void InitTriedron();

	void InitBgColors();

	void UpdateGrid();

// 操作
public:

	Handle(V3d_Viewer) GetViewer(void) { return myViewer; }

	//! Get current action.
	CurAction3d getCurrentAction() const { return myCurrentMode; }

	//! Set current action.
	void setCurrentAction(CurAction3d theAction)
	{
		myCurrentMode = theAction;
	}

// 重写
public:
	virtual void OnDraw(CDC* pDC);  // 重写以绘制该视图
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// 实现
public:
	virtual ~CMFCApplication1View();
	virtual void OnInitialUpdate();

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	Handle(AIS_InteractiveContext) myAisContext;
	Handle(V3d_Viewer)	myViewer;
	Handle(V3d_View)	myView;

	Handle(AIS_MyGrid) myFixedGrid;

	CurAction3d         myCurrentMode;

	Standard_Integer	myZLayerID;
	Standard_Integer    myXmin;
	Standard_Integer    myYmin;
	Standard_Integer    myXmax;
	Standard_Integer    myYmax;

	Standard_Boolean	myShowEdge;
	Standard_Boolean	myShowGrid;

	SelectionTool* m_pSelectionTool;

	TopTools_ListOfShape myFaceList;

	Handle(AIS_Shape) myAisShape;


	void UpdateOccView();

//	Handle(AIS_Shape) GetAisShape(TopoDS_Shape shape);

	void SetShapeColor(Handle(AIS_Shape) shape);

	TopoDS_Shape ReverseFaceOrientation(const TopoDS_Shape& shape, const TopoDS_Face& face);

	void ShowTopoDsShape(TopoDS_Shape aTopoDsShape);
	void ShowAisInteractiveShape(Handle(AIS_InteractiveObject) aAisInteractiveShape);

	IFSelect_ReturnStatus ReadSTEP(const Standard_CString& aFileName,
		Handle(TopTools_HSequenceOfShape)& aHSequenceOfShape);

	void SaveTopoInfo(const TopoDS_Shape& aTopoDsShape);

// 生成的消息映射函数
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnCreateBox();
	afx_msg void OnCreateCylinder();
	afx_msg void OnCreateSphere();
	afx_msg void OnCreateBottle();
	afx_msg void OnTopView();
	afx_msg void OnSideView();
	afx_msg void OnFrontView();
	afx_msg void OnIsoView();
	afx_msg void OnFitAll();

	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);

	afx_msg void On2dLine();
	afx_msg void On2dArc();
	afx_msg void On3dPoint();
	afx_msg void On3dLine();
	afx_msg void On3dSpline();
	afx_msg void OnPlane();
	afx_msg void OnCylinder();
	afx_msg void OnParabola();

	afx_msg void OnUpdateShowEdge(CCmdUI *pCmdUI);
	afx_msg void OnShowEdge();
	afx_msg void OnLineAspect();
	afx_msg void OnDatumCircle();
	afx_msg void OnDatumAxis();
	afx_msg void OnDatumPlane();
	afx_msg void OnDatumTrihedron();
	afx_msg void OnDatumPoint();
	afx_msg void OnSelectVertex();
	afx_msg void OnSelectFace();
	afx_msg void OnSelectEdge();
	afx_msg void OnSelectSolid();
	afx_msg void OnImportIgesFile();
	afx_msg void OnImportStepFile();
	afx_msg void OnShowGrid();
	afx_msg void OnUpdateShowGrid(CCmdUI *pCmdUI);
	afx_msg void OnSelectRoundSlot();
	afx_msg void OnRectSlotSelect();
	afx_msg void OnUpdateSelectRectSlot(CCmdUI *pCmdUI);
	afx_msg void OnUpdateSelectRoundSlot(CCmdUI *pCmdUI);
	afx_msg void OnLine2Bspline();
	afx_msg void OnCircle2Bspline();
	afx_msg void OnViewAnimation();
	afx_msg void OnUserDefined2dAisObject();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void On3dPointTo2dPoint();
	afx_msg void OnFixedGrid();
	afx_msg void OnPointCloud();
	afx_msg void OnCone();
	afx_msg void OnIsoSurface();
};

#ifndef _DEBUG  // MFCApplication1View.cpp 中的调试版本
inline CMFCApplication1Doc* CMFCApplication1View::GetDocument() const
   { return reinterpret_cast<CMFCApplication1Doc*>(m_pDocument); }
#endif

